import axios from 'axios'
import api_url from './config.js'


const request = axios.create({
	baseURL: api_url,
	timeout: 6 * 1000
})

const err = (error) => {
	console.og(error);
}

request.interceptors.request.use(config => {
	return config;
}, err);

request.interceptors.response.use(res => {
	return new Promise((resolve, reject) => {
		if(res.status == 401) {
			reject(res)
		}
		else {
			resolve(res)
		}
	})
}, err)


export default {
	get(url, data) {
		request({
			url,
			data,
			method: 'get'
		})
	},
	post(url, data) {
		request({
			url,
			data,
			method: 'post'
		})
	},
}